{*
* 2007-2011 PrestaShop 
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <contact@prestashop.com>
*  @copyright  2007-2011 PrestaShop SA
*  @version  Release: $Revision: 6594 $
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}

<!-- Block user information module HEADER -->
<div id="header_user">
	<div id="header_user_left">
		
		<p id="header_user_info">
			{l s='Welcome' mod='blockuserinfo'},
			{if $cookie->isLogged()}
				<span>{$cookie->customer_firstname} {$cookie->customer_lastname}</span>
				(<a href="{$link->getPageLink('index.php')}?mylogout" title="{l s='Log me out' mod='blockuserinfo'}">{l s='Log out' mod='blockuserinfo'}</a>)
				&nbsp;|&nbsp;<a href="{$site_url}my-account.php" title="My Account">My Account</a>
			{else}
				<a href="{$link->getPageLink('my-account.php', true)}">{l s='Log in' mod='blockuserinfo'}</a>
			{/if}
		</p>
		
		<div class="dl_clear"></div>
		
		<ul id="header_nav">
			
			<!--<li><a href="{$site_url}cms.php?id_cms=6" title="Sizing">Sizing</a></li>-->
			<li><a href="{$site_url}cms.php?id_cms=5" title="FAQ">FAQ</a></li>
			<li><a href="{$site_url}contact-form.php" title="Contact Us">Contact Us</a></li>
			
			{if !$PS_CATALOG_MODE}
			<li id="shopping_cart">
				<a href="{$link->getPageLink("$order_process.php", true)}" title="{l s='Your Shopping Cart' mod='blockuserinfo'}">{l s='View Cart:' mod='blockuserinfo'}</a>
				(
				<span class="cart_quantity">{$cart_qties}</span>
				<!--<span class="ajax_cart_product_txt">{l s='product' mod='blockuserinfo'}</span>-->
				<span class="cart_product_txt_s">Items</span>
				/ 
				{if $cart_qties >= 0}
					<span class="cart_total">
						{if $priceDisplay == 1}
							{assign var='blockuser_cart_flag' value='Cart::BOTH_WITHOUT_SHIPPING'|constant}
							{convertPrice price=$cart->getOrderTotal(false, $blockuser_cart_flag)}
						{else}
							{assign var='blockuser_cart_flag' value='Cart::BOTH_WITHOUT_SHIPPING'|constant}
							{convertPrice price=$cart->getOrderTotal(true, $blockuser_cart_flag)}
						{/if}
					</span>
				{/if}
				<!--<span class="cart_no_product{if $cart_qties > 0} hidden{/if}">$0.00</span>-->
				)
			</li>
			{/if}
		</ul>
		<div class="dl_clear"></div>
	</div>
	
	<div id="user_search_frm">
		<!-- Block search module -->
		<div id="user_join_frm">
			<form method="post" action="{$link->getPageLink('authentication.php', true)}" id="dl_join_frm">
				<p>
					<input class="join_query" type="text" id="join_query_block" name="email_create" value="Your email address"  onfocus="javascript:if(this.value=='Your email address')this.value='';" onblur="javascript:if(this.value=='')this.value='Your email address';" />
					<input type="submit" id="join_button" value="join" />
					<input type="hidden" class="hidden" name="SubmitCreate" value="Create your account" />
				</p>
			</form>
		</div>
		<div id="search_block_left">
			<form method="get" action="{$link->getPageLink('search.php', true)}" id="searchbox">
				<p>
					<input type="hidden" name="orderby" value="position" />
					<input type="hidden" name="orderway" value="desc" />
					<input class="search_query" type="text" id="search_query_block" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|htmlentities:$ENT_QUOTES:'utf-8'|stripslashes}{else}Search{/if}" onfocus="javascript:if(this.value=='Search')this.value='';" onblur="javascript:if(this.value=='')this.value='Search';" />
					<input type="submit" id="search_button" value="{l s='go' mod='blocksearch'}" />
				</p>
			</form>
		</div>
		{if $instantsearch}
			<script type="text/javascript">
			// <![CDATA[
				{literal}
				function tryToCloseInstantSearch() {
					if ($('#old_center_column').length > 0)
					{
						$('#center_column').remove();
						$('#old_center_column').attr('id', 'center_column');
						$('#center_column').show();
						return false;
					}
				}
				
				instantSearchQueries = new Array();
				function stopInstantSearchQueries(){
					for(i=0;i<instantSearchQueries.length;i++) {
						instantSearchQueries[i].abort();
					}
					instantSearchQueries = new Array();
				}
				
				$("#search_query_block").keyup(function(){
					if($(this).val().length > 0){
						stopInstantSearchQueries();
						instantSearchQuery = $.ajax({
						url: '{/literal}{if $search_ssl == 1}{$link->getPageLink('search.php', true)}{else}{$link->getPageLink('search.php')}{/if}{literal}',
						data: 'instantSearch=1&id_lang={/literal}{$cookie->id_lang}{literal}&q='+$(this).val(),
						dataType: 'html',
						success: function(data){
							if($("#search_query_block").val().length > 0)
							{
								tryToCloseInstantSearch();
								$('#center_column').attr('id', 'old_center_column');
								$('#old_center_column').after('<div id="center_column">'+data+'</div>');
								$('#old_center_column').hide();
								$("#instant_search_results a.close").click(function() {
									$("#search_query_block").val('');
									return tryToCloseInstantSearch();
								});
								return false;
							}
							else
								tryToCloseInstantSearch();
							}
						});
						instantSearchQueries.push(instantSearchQuery);
					}
					else
						tryToCloseInstantSearch();
				});
			// ]]>
			{/literal}
			</script>
		{/if}
		
		{if $ajaxsearch}
			<script type="text/javascript">
			// <![CDATA[
			{literal}
				$('document').ready( function() {
					$("#search_query_block")
						.autocomplete(
							'{/literal}{if $search_ssl == 1}{$link->getPageLink('search.php', true)}{else}{$link->getPageLink('search.php')}{/if}{literal}', {
								minChars: 3,
								max: 10,
								width: 500,
								selectFirst: false,
								scroll: false,
								dataType: "json",
								formatItem: function(data, i, max, value, term) {
									return value;
								},
								parse: function(data) {
									var mytab = new Array();
									for (var i = 0; i < data.length; i++)
										mytab[mytab.length] = { data: data[i], value: data[i].cname + ' > ' + data[i].pname };
									return mytab;
								},
								extraParams: {
									ajaxSearch: 1,
									id_lang: {/literal}{$cookie->id_lang}{literal}
								}
							}
						)
						.result(function(event, data, formatted) {
							$('#search_query_block').val(data.pname);
							document.location.href = data.product_link;
						})
				});
			{/literal}
			// ]]>
			</script>
		{/if}
		<!-- /Block search module -->
	</div>
	<div class="dl_clear"></div>
</div>
<!-- /Block user information module HEADER -->
